//
//  distanceView.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/5/8.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "distanceView.h"
#import "disDescModel.h"
#import "config.h"
#define NameFont [UIFont systemFontOfSize:13]

@interface distanceView()
//中国城，唐人街
@property (weak, nonatomic) IBOutlet UILabel *localNameLab;
//距离多少公里
@property (weak, nonatomic) IBOutlet UILabel *distanceLab;
@property (nonatomic,assign)CGFloat  gap;

@end

@implementation distanceView
+(instancetype)distanceViewInitWithXib:(NSString *)distArr;
{
    distanceView *view = [[[NSBundle mainBundle]loadNibNamed:@"distanceView" owner:nil options:nil]lastObject];
    view.localNameLab.text = distArr;
//    [view.distanceLab setPreferredMaxLayoutWidth:UIScreenWidth - 107 -10];
//    [view.distanceLab layoutIfNeeded];
  
    return view;
}

-(CGFloat)getHightwithModel:(disDescModel *)model
{
    CGFloat labW = UIScreenWidth - 107 -10;
    CGSize nameMaxSize = CGSizeMake(labW,MAXFLOAT);
    NSDictionary *attrs =@{NSFontAttributeName:NameFont};
    self.distanceLab.text = model.disDesc;
    CGFloat labH = [self.distanceLab.text  boundingRectWithSize:nameMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size.width;
    
    return 35+labH - 20;
}
-(void)setModel:(disDescModel *)model
{
    _model = model;
    self.localNameLab.text = model.lTypeName;
    self.distanceLab.text = model.disDesc;
    if([self.localNameLab.text isEqualToString:@"学区房"]){
        [self.localNameLab setBackgroundColor:UIColorFromRGB(0x58BF66)];
    }else if ([self.localNameLab.text isEqualToString:@"中国城房"])
    {
        [self.localNameLab setBackgroundColor:UIColorFromRGB(0xff5e5e)];
    }else{
        
        [self.localNameLab setBackgroundColor:UIColorFromRGB(0xdb2a2b)];
    }
   
    NSLog(@"差距－－－－%zd",self.distanceLab.frame.size.height - 21.0);
}


@end
